/**
 * 
 */
package com.devmindset.legoframework.client.mvc.metadata;

import com.devmindset.legoframework.client.mvc.LegoComponent;
import com.devmindset.legoframework.client.screen.ApplicationScreen;

/**
 * {@link Story} for a {@link ApplicationScreen}. 
 * 
 * @author <a href="mailto:ice.penov@devmindset.com">Ice Penov</a>
 */
public class ScreenStory implements Story {
  
  private LegoComponent[] consistsOf;
  private LegoComponent[] initialState;
  private PlaceholderMapping[] placeholderMappings;
  private String knownAs;
  
  /**
   * Constructor.
   */
  ScreenStory() {}
  
  /**
   * Declared of what {@link LegoComponent}s the {@link ApplicationScreen} consists of.
   * 
   * @param components the {@link LegoComponent}s
   * @return .
   */
  public ScreenStory consistsOf(LegoComponent...components) {
    this.consistsOf = components;
    return this;
  }
  
  /**
   * Declared of what {@link LegoComponent}s the {@link ApplicationScreen} will be
   * initially constructed.
   * 
   * @param components the {@link LegoComponent}s
   * @return .
   */
  public ScreenStory initialState(LegoComponent...components) {
    this.initialState = components;
    return this;
  }
  
  /**
   * Declares the mapping between the placeholders and components on the screen.
   * 
   * @param mappings the mappings
   * @return .
   */
  public ScreenStory placeholderMappings(PlaceholderMapping... mappings) {
  	this.placeholderMappings = mappings;
  	return this;
  }
  
  /**
   * Knows as - description string.
   * 
   * @param description the string
   * @return .
   */  
  public ScreenStory knownAs(String description) {
    this.knownAs = description;
    return this;
  }

  /**
   * Returns the consistsOf.
   *
   * @return the consistsOf
   */
  public LegoComponent[] getConsistsOf() {
    return consistsOf;
  }

  /**
   * Returns the initialState.
   *
   * @return the initialState
   */
  public LegoComponent[] getInitialState() {
    return initialState;
  }
    
  
  public PlaceholderMapping[] getPlaceholderMappings() {
		return placeholderMappings;
	}

	/**
   * Returns the knownAs.
   *
   * @return the knownAs
   */
  public String getKnownAs() {
    return knownAs;
  }
  
  /**
   * {@inheritDoc}.
   */
  @Override
  public String toString() {
    if (knownAs != null) {
      return knownAs;
    } else {
      return super.toString();
    }
  }
  
}